package com.soft.javase.day07.balancenotenoughexception;

/**
 * @author yzg
 * @desc TODO
 * @date 2025/4/26
 */
public class Account {
    private Long id;
    private double balance;

    public Account(Long id, double balance) {
        this.id = id;
        this.balance = balance;
    }

    public Account withdraw(double amount) throws BalanceNotEnoughException {
        if(this.balance>=amount){
            this.balance -= amount;
            return this;
        }
        throw new BalanceNotEnoughException("您的余额不足");
    }

    @Override
    public String toString() {
        return "Account{" +
                "id=" + id +
                ", balance=" + balance +
                '}';
    }
}
